const fs = require('fs')
const arr = [
    {name:'zhangsan',age:10},
    {name:'lisi',age:10},
    {name:'wangmazi',age:10}
]
const fileContent = arr.reduce((prev, item)=>
    prev + `${item.name}------${item.age}
`
,"")

fs.writeFileSync('testtest.txt', fileContent, 'utf-8')